package org.springframework.extend.persistence.repository;

import java.util.Map;

import org.springframework.util.StringUtils;

public class ExtendXmlPersistenceRepository implements PersistenceRepository {

	private Map<String, SqlResource>	resources;

	public SqlResource findSqlResource(String queryId) {
		if (!StringUtils.hasText(queryId)) {
			throw new IllegalArgumentException("Query ID is required!");
		}
		SqlResource resource = resources.get(queryId);

		if (resource == null) {
			throw new NoSuchResourceException("Target resource is not exist.[request id: " + queryId + "]");
		}
		return resource;
	}

	public void setResources(Map<String, SqlResource> resources) {
		this.resources = resources;
	}

	public Map<String, SqlResource> getResources() {
		return resources;
	}

}
